import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'

const router = createRouter({
  history: createWebHistory('/'),
  routes: [
    {
      path: '/',
      name: 'home',
      component: HomeView,
      meta: {
        title: '首页 - 舆情监控系统'
      }
    },
    {
      path: '/sentiment',
      name: 'sentiment',
      component: () => import('../views/SentimentAnalysisView.vue'),
      meta: {
        title: '情感详情分析 - 舆情监控系统'
      }
    },
    {
      path: '/keywords',
      name: 'keywords',
      component: () => import('../views/KeywordMonitorView.vue'),
      meta: {
        title: '关键词监控 - 舆情监控系统'
      }
    },
    {
      path: '/platform-comparison',
      name: 'PlatformComparison',
      component: () => import('../views/PlatformComparisonView.vue'),
      meta: {
        title: '平台数据对比',
        requiresAuth: true
      }
    },
    {
      path: '/monitor-targets',
      name: 'MonitorTargets',
      component: () => import('../views/MonitorTargetsView.vue'),
      meta: {
        title: '监控目标管理',
        requiresAuth: true
      }
    },
    {
      path: '/:pathMatch(.*)*',
      name: 'not-found',
      component: () => import('../views/NotFoundView.vue'),
      meta: {
        title: '页面未找到 - 舆情监控系统'
      }
    }
  ]
})

// 路由标题设置
router.beforeEach((to, from, next) => {
  // 如果路由配置了标题，就设置文档标题
  if (to.meta.title) {
    document.title = to.meta.title as string
  }
  next()
})

export default router 